{extend name="base"}
{block name="title"}用户详情{/block}
{block name="head"}
<script src="http://api.map.baidu.com/api?v=3.0&ak=4mAuNG1QQqFSHV7mjMFVeNjkxgPpqlXh"></script>
<style>
  th {text-align: center;}
td.detail{padding:0;}
td.detail table.border-table{width:100%; border:0;}
input.more{margin-bottom:10px;}
table.yeji td{text-align:right}
</style>
{/block}
{block name="body"}
<body class="mainbody">

  <!--导航栏-->
  <div class="location">
    <a href="javascript:history.back(-1);" class="back"><i class="iconfont icon-up"></i><span>返回上一页</span></a>
    <a href="{:url('index/home')}" class="home"><i class="iconfont icon-home"></i><span>首页</span></a>
    <i class="arrow iconfont icon-arrow-right"></i>
    <span>用户详情</span>
  </div>
  <!--/导航栏-->

  <!--提示-->
  <div id="floatHead" class="content-tab-wrap">
    <div class="content-tab">
      <div class="content-tab-ul-wrap">
        <ul>
          <li><a class="selected">基本信息</a></li>
          <li><a>帐号权限</a></li>
          <li><a>登陆记录({$UserLoginCount})</a></li>
          <li><a>房卡记录({$RoomCardCount}) 消耗({$RoomCardSum})</a></li>
          <li><a>充值记录({$ChargeOnlineCount}) 消费({$ChargeOnlineSum})</a></li>
          <li><a>房卡游戏记录({$GameRecordCount})</a></li>
          <li><a>金币游戏记录({$RecordDrawScoreCount})</a></li>
          <li><a>背包物品({$BackpackCount})</a></li>
          {eq name="User.AccountsType" value="1"}<li><a>绑定记录({$AgnetBindCount})</a></li>{/eq}
          {eq name="User.AccountsType" value="1"}<li><a>代理设置</a></li>{/eq}
          {eq name="User.AccountsType" value="1"}<li><a>综合业绩</a></li>{/eq}
        </ul>
      </div>
    </div>
  </div>
  <!--内容-->

  <!--基本信息-->
  <div class="tab-content">
    <table class="border-table">
      <tr>
        <th>用户标识</th><td>{$User.UserID}</td>
        <th>游戏标识</th>
        <td>{$User.GameID}
          {eq name="User.AccountsType" value="1"}<input type="button" name="btnGiveGameID" value="赠送靓号" />{/eq}
        </td>
        <th rowspan="4">头像<br/>[{$User.Sex}]{switch name='User.Sex'}{case value='0'}未知{/case}{case value='1'}男性{/case}{case value='2'}女性{/case}{/switch}</th>
        <td rowspan="4">
          <a target="_blank" href="{$User.HeadImgUrl?:'__STATIC__/houtai/images/dface.png'}" style="display:inline-block;width:132px;height:132px;">
            <img src="{$User.HeadImgUrl?:'__STATIC__/houtai/images/dface.png'}" />
          </a>
        </td>
      </tr>
      <tr>
        <th>渠道标识</th><td>[{$User.Channel}]{$User.ChannelName ?? '--'}</td>
        <th>注册来源</th><td>[{$User.PlatformID}]{$LOGIN_TYPE[$User.PlatformID]??'--'}</td>
      </tr>
      <tr>
        <th>用户帐号</th><td>{$User.Accounts|htmlentities}</td>
        <th>手机号码</th><td>{$User.RegisterMobile}</td>
      </tr>
      <tr>
        <th>游戏昵称</th><td><a class="at_{$User.AccountsType}">{$User.NickName|htmlentities}</a></td>
        <th>账号类型</th><td><a class="at_{$User.AccountsType}">[{$User.AccountsType}]{$ACCOUNTS_TYPE[$User.AccountsType]??'--'}</a></td>
      </tr>
      <tr>
        <th>真实姓名</th><td>{$User.Compellation}</td>
        <th>身份证号</th><td>{$User.PassPortID}</td>
        <th>微信UnionID</th><td>{$User.UserUin}</td>
      </tr>
      <tr>
        <th>登录IP</th><td>{$User.LastLogonIP}</td>
        <th>登录时间</th><td>{$User.LastLogonDate}</td>
        <th>登录机器</th><td>{$User.LastLogonMachine}</td>
      </tr>
      <tr>
        <th>注册IP</th><td>{$User.RegisterIP}</td>
        <th>注册时间</th><td>{$User.RegisterDate}</td>
        <th>注册机器</th><td>{$User.RegisterMachine}</td>
      </tr>
      <tr>
        <th>身上金币</th>
        <td>{$User.Score}
          <input type="button" name="btnGiveCoin" value="赠送金币" />
        </td>
        <th>银行金币</th><td>{$User.InsureScore}</td>
        {eq name="User.AccountsType" value="1"}
          <th>上级代理</th>
          <td>
            {gt name="AgentBase.PUserID" value="0"}
              <a class="at_1" target="_blank" href="{:url('user.detail/index')}?UserID={$AgentBase.PUserID}">[{$AgentBase.PGameID}]{$AgentBase.PCompellation}</a>
            {else/}
              <a class="at_1">无</a>
            {/gt}
          </td>
        {else/}
          <th></th><td></td>
        {/eq}
      </tr>

      <tr>
        <th>小游戏</th>
        <td colspan="6" class="detail">
          <table class="border-table">
            <tr>
              <th>#</th>
              <th>({$User.RoomCard})拥有房卡</th>
            {neq name="User.AccountsType" value="1"}
              <th>所属代理</th>
              <th>绑定时间</th>
            {/neq}
              <th>经验值</th>
              <th>操作</th>
            </tr>
{empty name="listCKSR"}
      <tr><td colspan="{eq name='User.AccountsType' value='1'}4{else/}6{/eq}">Oh~暂无数据!</td></tr>
{else}
      {volist name="listCKSR" id="v"}
            <tr data-kind="">
              <td>{$i}</td>
              <td class="tr">{$v.RoomCard}</td>
            {neq name="User.AccountsType" value="1"}
              <td>{gt name="v.SpreaderID" value="0"}{php}$ag = $listAgent[$v['SpreaderID']] ?? [];{/php}
                <a target="_blank" class="at_{$ag.AccountsType??0}" href="{:url('user.detail/index')}?UserID={$ag.UserID??0}">[{$ag.GameID??0}]{$ag.Compellation??''}</a>
              {/gt}</td>
              <td>{$v.SpreaderTime}</td>
            {/neq}
              <td>{$User.Experience}</td>
              <td>
                <input type="button" value="赠送房卡" name="btnZeng" />&nbsp;
                {neq name="v.RoomCard" value="0"}<input type="button" value="清零房卡" name="btnClear" />&nbsp;{/neq}
              {neq name="User.AccountsType" value="1"}
                {eq name="v.SpreaderID" value="0"}<input type="button" value="绑定代理" name="btnBindAgent" />&nbsp;{/eq}
                {gt name="v.SpreaderID" value="0"}<input type="button" value="清空绑定" name="btnClearAgent" />&nbsp;{/gt}
              {/neq}
              </td>
            </tr>
      {/volist}
{/empty}
          </table>
        </td>
      </tr>
      <tr>
        <th>地图定位</th>
        <td colspan="5" style="padding:0">
          <div id="allmap" style="height:320px;width:100%;"><!-- 百度地图容器 --></div>
        </td>
      </tr>
    </table>
  </div>
  <!--/基本信息-->

  <!--帐号权限-->
  <div class="tab-content" style="display: none;">
    <dl>
      <dt>冻结帐号</dt>
      <dd>
        <div class="rule-single-checkbox">
          <input type="checkbox" name="txtNullity" value="1"{eq name="User.Nullity" value="1"} checked{/eq} />
        </div>
      </dd>
    </dl>
    <dl>
      <dt>安全关闭</dt>
      <dd>
        <div class="rule-single-checkbox">
          <input type="checkbox" name="txtStunDown" value="1"{eq name="User.StunDown" value="1"} checked{/eq} />
        </div>
      </dd>
    </dl>
    <dl>
      <dt>设为机器人</dt>
      <dd>
        <div class="rule-single-checkbox">
          <input type="checkbox" name="txtIsAndroid" value="3"{eq name="User.AccountsType" value="3"} checked{/eq} />
        </div>
      </dd>
    </dl>
    <dl>
      <dt>锁定机器</dt>
      <dd>
        <div class="rule-single-checkbox">
          <input type="checkbox" name="txtMoorMachine" value="1"{eq name="User.MoorMachine" value="1"} checked{/eq} />
        </div>
      </dd>
    </dl>
    <dl>
      <dt title="UserRight">用户权限({$User.UserRight})</dt>
      <dd>
        <div class="rule-multi-porp">
          <span>{php}$temp=[
            0=>'不能进行游戏',
            1=>'不能旁观游戏',
            2=>'不能发送私聊',
            3=>'不能大厅聊天',
            4=>'不能游戏聊天',
            5=>'游戏踢出用户',
            6=>'是否小号游戏',
            7=>'是否微信支付',
            8=>'禁止更新IP',
          ];{/php}
          {volist name="temp" id="val"}
            <input type="checkbox" name="txtUserRight[{$key}]" value="1"{if condition="$User.UserRight&1<<$key"} checked{/if} /><label>{$key}={$val}</label>
          {/volist}
          </span>
        </div>
      </dd>
    </dl>
    <dl>
      <dt>用户身份</dt>
      <dd>
        <div class="rule-multi-radio">
          <span style="display: none;">{php}$temp=[0=>'普通玩家',1=>'管理员'];{/php}
          {foreach name="temp" item="val"}
            <input type="radio" name="txtMasterOrder" value="{$key}"{eq name="User.UserRight" value="$key"} checked{/eq} /><label>{$key}={$val}</label>
          {/foreach}
          </span>
        </div>
      </dd>
    </dl>
    <dl>
      <dt title="MasterRight">管理权限({$User.UserRight})</dt>
      <dd>
        <div class="rule-multi-porp">
          <span>{php}$temp=[
            0=>'允许禁止游戏',
            1=>'允许禁止旁观',
            2=>'允许禁止私聊',
            3=>'允许禁止房间聊天',
            4=>'允许禁止游戏聊天',
            5=>'允许踢出用户',
            6=>'允许解散游戏',
            7=>'允许发布消息',
            8=>'允许管理房间',
            9=>'允许管理机器人',
          ];{/php}
          {foreach name="temp" item="val"}
            <input type="checkbox" name="txtMasterRight[{$key}]" value="1"{if condition="$User.UserRight&1<<$key"} checked{/if} /><label>{$key}={$val}</label>
          {/foreach}
          </span>
        </div>
      </dd>
    </dl>
    <dl>
      <dt>&nbsp;</dt>
      <dd>
        <input type="button" name="btnSaveRight" value="提交保存" class="btn yellow" />
      </dd>
    </dl>

  </div>
  <!--/帐号权限-->

  <!--登陆记录-->
  <div class="tab-content" style="display: none;">
    <input class="more" type="button" value="查看完整数据" onclick="window.open('{:url('user.login/index')}?search={$User.UserID}')" />
    <table class="border-table">
      <tr>
        <th>序号</th>
        <th>自动编号</th>
        <th>登陆类型</th>
        <th>登陆时间</th>
        <th>机器码</th>
        <th>登陆IP</th>
        <th>OpenID</th>
      </tr>
{empty name="listLogin"}
      <tr><td colspan="7">Oh~暂无数据!</td></tr>
{else}
      {volist name="listLogin" id="v"}
      <tr>
        <td>{$i}</td>
        <td>{$v.RecordID}</td>
        <td>[{$v.LoginType}]{$LOGIN_TYPE[$v.LoginType] ?? '--'}</td>
        <td>{$v.LoginTime}</td>
        <td>{$v.MoorMachine}</td>
        <td>{$v.LoginIP}</td>
        <td>{$v.OpenID}</td>
      </tr>
      {/volist}
{/empty}
    </table>
  </div>
  <!--/登陆记录-->

  <!--房卡记录-->
  <div class="tab-content" style="display: none;">
    <input class="more" type="button" value="查看完整数据" onclick="window.open('{:url('user.room.card/index')}?search={$User.UserID}')" />
    <table class="border-table">
      <tr>
        <th>序号</th>
        <th>自动编号</th>
        <th>房卡数量</th>
        <th>剩余房卡</th>
        <th>备注</th>
        <th>操作时间</th>
      </tr>
{empty name="listCard"}
      <tr><td colspan="6">Oh~暂无数据!</td></tr>
{else}
      {volist name="listCard" id="v"}
      <tr>
        <td>{$i}</td>
        <td>{$v.RecordID}</td>
        <td>{$v.dwCost}</td>
        <td>{$v.beleftRoomCard}</td>
        <td>{$v.describe}</td>
        <td>{$v.CostTime}</td>
      </tr>
      {/volist}
{/empty}
    </table>
  </div>
  <!--/房卡记录-->

  <!--充值记录-->
  <div class="tab-content" style="display: none;">
    <input class="more" type="button" value="查看完整数据" onclick="window.open('{:url('user.pay/index')}?search={$User.GameID}')" />
    <table class="border-table">
      <tr>
        <th>自动编号</th>
        <th>游戏</th>
        <th>内部订单号</th>
        <th>金额</th>
        <th>订单状态</th>
        <th>发货状态</th>
        <th>支付类型</th>
        <th>下单IP</th>
        <th>下单时间</th>
        <th>更新时间</th>
      </tr>
{empty name="listPay"}
      <tr><td colspan="10">Oh~暂无数据!</td></tr>
{else}
      {volist name="listPay" id="v"}
      <tr>
        <td>{$v.ID}</td>
        <td>[{$v.KindID}]{$v.KindName}</td>
        <td>{$v.MerBillNo}</td>
        <td>{$v.RMB}</td>
        <td class="sp_{$v.Status}">[{$v.Status}]{$STATE_PAY[$v.Status] ?? '--'}</td>
        <td class="so_{$v.GameStatus}">[{$v.GameStatus}]{$STATE_ORD[$v.GameStatus] ?? '--'}</td>
        <td>{$v.PayType}</td>
        <td>{$v.wwwIp}</td>
        <td>{$v.Addtime}</td>
        <td>{$v.Updatetime}</td>
      </tr>
      {/volist}
{/empty}

    </table>
  </div>
  <!--/充值记录-->

  <!--房卡游戏记录-->
  <div class="tab-content" style="display: none;">
    <input class="more" type="button" value="查看完整数据" onclick="window.open('{:url('user.game/index')}?search={$User.UserID}')" />
    <table class="border-table">
      <tr>
        <th>自动编号</th>
        <th>游戏</th>
        <th>输赢</th>
        <th>底分</th>
        <th>得分</th>
        <th>房间号</th>
        <th>游戏时间</th>
      </tr>
{empty name="listGame"}
      <tr><td colspan="7">Oh~暂无数据!</td></tr>
{else}
      {volist name="listGame" id="v"}
      <tr>
        <td>{$v.ID}</td>
        <td>[{$v.dwKindID}][{$v.KindName}]</td>
        <td class="tr{gt name='v.lScore' value='0'} red{/gt}">{$v.lScore}</td>
        <td class="tr">{$v.Difen/10}</td>
        <td class="tr{gt name='v.lScore' value='0'} red{/gt}">${$v.zScore|round}</td>
        <td><a target="_blank" href="{:url('user.game/detail')}?id={$v.ID}">[{$v.RoomID}][{$v.ServerName ?? ''}]</a></td>
        <td>{$v.CreateTime}</td>
      </tr>
      {/volist}
{/empty}
    </table>
  </div>
  <!--/房卡游戏记录-->


  <!--金币游戏记录-->
  <div class="tab-content" style="display: none;">
    <input class="more" type="button" value="查看完整数据" onclick="window.open('{:url('user.glod.glod/index')}?UserID={$User.UserID}')" />
    <table class="border-table">
      <tr>
        <th>自动编号</th>
        <th>游戏</th>
        <th>输赢</th>
        <th>局数标识</th>
        <th>游戏时间</th>
      </tr>
      {empty name="listScore"}
      <tr><td colspan="7">Oh~暂无数据!</td></tr>
      {else}
      {volist name="listScore" id="v"}
      <tr>
        <td>{$v.DrawID}</td>
        <td>[{$v.KindID}][{$v.KindName}]</td>
        <td class="tr{gt name='v.Score' value='0'} red{/gt}">{$v.Score}</td>
        <td><a target="_blank" href="{:url('user.glod.glod/detail')}?DrawID={$v.DrawID}">[{$v.DrawID}][{$v.ServerName}]</a></td>
        <td>{$v.StartTime}至{$v.ConcludeTime}</td>
      </tr>
      {/volist}
      {/empty}
    </table>
  </div>
  <!--/金币游戏记录-->

  <!--背包物品-->
  <div class="tab-content" style="display: none;">
    <table class="border-table">
      <tr>
        <th>索引</th>
        <th>名称</th>
        <th>数量</th>
        <th>创建时间</th>
        <th>修改时间</th>
      </tr>
      {empty name="listBackpack"}
      <tr><td colspan="7">Oh~暂无数据!</td></tr>
      {else}
      {volist name="listBackpack" id="v"}
      <tr>
        <td>{$v.BackIndex}</td>
        <td>{$v.Name}</td>
        <td >{$v.ItemNum}</td>
        <td>{$v.CreateTime}</td>
        <td>{$v.UpdateTime}}</td>
      </tr>
      {/volist}
      {/empty}
    </table>
  </div>
  <!--/背包物品-->


{eq name="User.AccountsType" value="1"}
  <!--绑定记录-->
  <div class="tab-content" style="display: none;">
    <input class="more" type="button" value="查看完整数据" onclick="window.open('{:url('user.agent.bind/index')}?search2={$User.GameID}')" />
    <table class="border-table">
      <tr>
        <th>自动编号</th>
        <th>用户标识</th>
        <th>用户昵称/头像/注册时间</th>
        <th>拥有房卡</th>
        <th>绑定时间</th>
        <th>累计充值</th>
        <th>开房次数</th>
        <th>玩整次数</th>
      </tr>
{empty name="listBind"}
      <tr><td colspan="9">Oh~暂无数据!</td></tr>
{else}
      {volist name="listBind" id="v"}
      <tr>
        <td>{$i}</td>
        <td>{$v.GameID}</td>
        <td class="user-avatar">
          <a target="_blank" href="{:url('user.detail/index')}?UserID={$v.UserID}">
            <img src="{$v.HeadImgUrl?:'__STATIC__/houtai/images/dface.png'}" />
          </a>
          <div class="user-box">
            <h4><a target="_blank" class="at_{$v.AccountsType}" href="{:url('user.detail/index')}?UserID={$v.UserID}">{:htmlentities($v.NickName)}</a></h4>
            <i>{$v.RegisterDate}</i>
          </div>
        </td>
        <td>{$v.RoomCard * 1}</td>
        <td>{$v.SpreaderIDBindTime  }</td>
        <td>{$v.PayALL * 1}</td>
        <td>{$v.PlayCount * 1}</td>
        <td>{$v.OverCount * 1}</td>
      </tr>
      {/volist}
{/empty}
    </table>
  </div>
  <!--/绑定记录-->
{/eq}

{eq name="User.AccountsType" value="1"}
  <!--代理设置-->
  <div class="tab-content" style="display: none;">
    <dl>
      <dt>代理地区</dt>
      <dd>
        <div class="rule-multi-radio">
          <span style="display: none;">
            {volist name="AGENT_TYPE" id="v"}
            <input type="radio" name="txtAgentType" value="{$key}"{eq name="Agent.AgentType" value="$key"} checked{/eq}/><label>[{$key}]{$v}</label>
            {/volist}
          </span>
        </div>
      </dd>
    </dl>
    
    <dl>
      <dt>菜单管理</dt>
      <dd>
        <div class="rule-multi-porp">
          <div style="display:none">{php}$temp = explode('_', str_replace('__', '_', trim($Agent['MenuStr'], '_')));{/php}
            {volist name="WX_AGENT_MENUS" id="v"}
            <input type="checkbox" name="txtNavStr[]" value="{$key}"{if condition="in_array($key, $temp)"} checked{/if} /><label>{$v[1]}({$key})</label>
            {/volist}
          </div>
        </div>
      </dd>
    </dl>

    <dl>
      <dt>上级代理</dt>
      <dd><input type="text" class="input normal" name="txtParentId" value="{$Agent.ParentId}" style="width:80px" autocomplete="off" />(请输入用户标识, 非游戏标识, 0为无上级)</dd>
    </dl>
<!--
    <dl>
      <dt>所有下级ID列表</dt>
      <dd><textarea class="input" name="txtMyAgent" style="width:490px;height:90px;">{$Agent.MyAgent}</textarea>(以“,”逗号区分开)</dd>
    </dl>
--->
    <dl>
      <dt>代理级别</dt>
      <dd>
        <div class="rule-multi-radio">
          <div style="display:none">{php}$temp = ['一级','二级','三级','四级','五级','六级','七级'];{/php}
            {volist name="temp" id="v"}
            <input type="radio" name="txtAgentLevel" value="{$key+1}"{eq name="Agent.AgentLevel" value="$key+1"} checked{/eq} /><label>{$v}代理</label>
            {/volist}
          </div>
        </div>
      </dd>
    </dl>
    
    <dl>
      <dt>是否直销</dt>
      <dd>
        <div class="rule-single-checkbox">
          <input type="checkbox" value="1" name="txtIsDirect"{eq name="Agent.IsDirect" value="1"} checked{/eq} />
        </div>
      </dd>
    </dl>
    <dl>
      <dt>禁止登陆</dt>
      <dd>
        <div class="rule-single-checkbox">
          <input type="checkbox" value="1" name="txtDisableLogin"{eq name="Agent.DisableLogin" value="1"} checked{/eq} />*公众号代理后台(否:可以正常登陆)(是:禁止登陆,返点,绑定无影响)
        </div>
      </dd>
    </dl>
    <dl>
      <dt>直销返点</dt>
      <dd><input type="text" class="input normal" name="txtDirectLevel" value="{$Agent.IsDirect ? $Agent.DirectLevel : 0}" style="width:80px;" autocomplete="off" />%</dd>
    </dl>
    <dl>
      <dt>返点比率</dt>
      <dd>{php}$temp = ['一级','二级','三级','四级','五级','六级','七级'];{/php}
        {foreach name="temp" item="v" key="k"}
        {$v}<input type="text" class="input normal" maxlength="3" name="txtLevel[]" value="{$Agent['level'.$k]??0}" style="width:40px;" autocomplete="off" />%&nbsp;
        {/foreach}
      </dd>
    </dl>
    
    <dl>
      <dt>所关联群</dt>
      <dd><input type="text" class="input normal" name="txtAssoFamily" value="{$Agent.AssoFamily}" style="width:280px" autocomplete="off" />(填六位群号,多个以英文“,”逗号区分开)</dd>
    </dl>
    
    <dl>
      <dt>支付级别</dt>
      <dd><input type="text" class="input normal" name="tetPayLv" value="{$Agent.PayLv}" style="width:80px" autocomplete="off" />(代理后台支付面额分组, 1=V1,2=V2,以此类推, V1和V2面额已预定义)</dd>
    </dl>
    
    <dl>
      <dt>&nbsp;</dt>
      <dd>
        <input type="button" name="btnSaveAgent" value="提交保存" class="btn yellow" />
      </dd>
    </dl>

  </div>
  <!--代理设置-->
{/eq}

{eq name="User.AccountsType" value="1"}
  <!-- 综合业绩 -->
  <div class="tab-content" style="display: none;">
    <div class="table-container">
      <table class="border-table yeji">
        <tr>
          <th>#</th>
          <th>充值</th>
          <th>佣金</th>
          <th>利润</th>
        </tr>
{empty name="listYeji"}
        <tr><td colspan="4">Oh~暂无数据!</td></tr>
{else}
      {volist name="listYeji" id="v"}
        <tr><th>{$v.b}</th><td>{$v.e*1}</td><td>{$v.f*1}</td><td>{$v.e*1-$v.f*1}</td></tr>
      {/volist}
{/empty}
      </table>
    </div>
  </div>
  <!-- 综合业绩 -->
{/eq}

<script>
$(function () {

  function initBMap(lng, lat) {
    var map = new BMap.Map("allmap"); //创建Map实例
    map.centerAndZoom(new BMap.Point(lng, lat), 15);
    map.enableScrollWheelZoom(); //添加鼠标滚动缩放
    map.addControl(new BMap.OverviewMapControl({
        isOpen: false,
        anchor: BMAP_ANCHOR_BOTTOM_RIGHT
      })); //添加缩略图控件
    map.addControl(new BMap.NavigationControl()); //添加缩放平移控件
    map.addControl(new BMap.ScaleControl()); //添加比例尺控件
    map.addControl(new BMap.MapTypeControl()); //添加地图类型控件
    var marker = new BMap.Marker(new BMap.Point(lng, lat)); // 创建标注
    map.addOverlay(marker); // 将标注添加到地图中
  }
  
  (function(){
    var pos = {
      lng: '{$User.nRadius??0}', // 经度
      lat: '{$User.sRadius??0}', // 纬度
      lip: "{$User.LastLogonIP??''}" // 最后登录IP
    };
    console.log(pos);
    if (pos.lng == 0 || pos.lat == 0) {
      console.warn("经纬度无效, 尝试IP定位", pos.lip);
      if (pos.lip == '' || pos.lip == '0.0.0.0' || pos.lip == '127.0.0.1') {
        // console.error("IP无效, 统一定位天安门坐标");
        initBMap(116.404, 39.915);
      } else {
        $.getJSON('https://api.map.baidu.com/location/ip?callback=?', {
          ip: pos.lip,
          ak: '4mAuNG1QQqFSHV7mjMFVeNjkxgPpqlXh',
          sn: '',
          coor: 'bd09ll'
        }, function (resp, text, xhr) {
          console.log(resp);
          if (resp.status != 0) {
            console.log("IP定位失败, 错误码请参考", 'http://lbsyun.baidu.com/index.php?title=webapi/ip-api');
            return;
          }
          var p = resp.content.point;
          console.log("IP所在城市中心点经度", p);
          initBMap(p.x, p.y)
        });
      }
    } else {
      var convertor = new BMap.Convertor();
      var wgPoint = new BMap.Point(pos.lng, pos.lat);
      convertor.translate([wgPoint], 1, 5, function (data) { // WGS84坐标=>bd09百度坐标系
        if (data.status != 0) {
          console.log("坐标转换失败", data);
          var p = wgPoint;
        } else {
          var p = data.points[0];
          console.log("坐标转换成功", p);
        }
        initBMap(p.lng, p.lat);
      });
    }
  })();
  
  // 赠送靓号
  $('input[name=btnGiveGameID]').click(function () {
    dialog({
      title: '赠送靓号',
      content: '<input type="text" class="input" placeholder="请输入要赠送的靓号" />',
      okValue: '确定',
      cancelValue: '取消',
      cancel: function () {},
      ok: function () {
        var a = $(this.node);
        var p = $('.input', a);
        var v = p.val();
        console.log(v);
        $.post("{:url('user.detail/zengGameID')}", {
          uid: "{$User.UserID}",
          nid: v
        }, function (resp, text, xhr) {
          console.log(resp);
          alert(resp.error);
          if (resp.errno == 0) {
            location.reload();
          }
        });
        return false;
      }
    }).showModal();
  });
  
  // 赠送金币
  $('input[name=btnGiveCoin]').click(function () {
    dialog({
      title: '赠送金币',
      content: '<input type="text" class="input" placeholder="请输入要赠送的金币数" />',
      okValue: '确定',
      cancelValue: '取消',
      cancel: function () {},
      ok: function () {
        var a = $(this.node);
        var p = $('.input', a);
        var v = p.val();
        console.log(v);
        $.post("{:url('user.detail/zengCoin')}", {
          uid: "{$User.UserID}",
          coin: v
        }, function (resp, text, xhr) {
          console.log(resp);
          alert(resp.error);
          if (resp.errno == 0) {
            location.reload();
          }
        });
        return false;
      }
    }).showModal();
  });
  
  // 赠送房卡
  $('input[name=btnZeng]').click(function () {
    var KindID = $(this).closest('tr').data('kind');
    dialog({
      title: '赠送房卡?KindID=' + KindID,
      content: '<input type="text" class="input" placeholder="请输入要赠送的房卡数" />',
      okValue: '确定',
      cancelValue: '取消',
      cancel: function () {},
      ok: function () {
        var a = $(this.node);
        var p = $('.input', a);
        var v = p.val();
        $.post("{:url('user.detail/zengRoomCard')}", {
          uid: "{$User.UserID}",
          zen: v,
          kind:KindID
        }, function (resp, text, xhr) {
          console.log(resp);
          alert(resp.error);
          if (resp.errno == 0) {
            location.reload();
          }
        });
        return false;
      }
    }).showModal();
  });
  
  // 清零房卡
  $('input[name=btnClear]').click(function () {
    var KindID = $(this).closest('tr').data('kind');
    dialog({
      title: '提示',
      content: '是否清零该用户的房卡?KindID=' + KindID,
      okValue: '确定',
      ok: function () {
        $.post("{:url('user.detail/clearRoomCard')}", {
          uid: "{$User.UserID}",
          kind: KindID
        }, function (resp, text, xhr) {
          console.log(resp);
          alert(resp.error);
          if (resp.errno == 0) {
            location.reload();
          }
        });
        return false;
      },
      cancelValue: '取消',
      cancel: function () {}
    }).showModal();
  });
  
  // 绑定代理
  $('input[name=btnBindAgent]').click(function () {
    var KindID = $(this).closest('tr').data('kind');
    dialog({
      title: '绑定代理?KindID=' + KindID,
      content: '<input type="text" class="input" placeholder="请输入六位优惠码" />',
      okValue: '确定',
      ok: function () {
        var a = $(this.node);
        var p = $('.input', a);
        var v = p.val();
        if (v <= 0) {
          return false;
        }
        $.post("{:url('user.detail/bindAgent')}", {
          uid: "{$User.UserID}",
          aid: v,
          kind: KindID
        }, function (resp, text, xhr) {
          console.log(resp);
          alert(resp.error);
          if (resp.errno == 0) {
            location.reload();
          }
        });
        return false;
      },
      cancelValue: '取消',
      cancel: function () {}
    }).showModal();
  });
  
  // 清空绑定
  $('input[name=btnClearAgent]').click(function () {
    var KindID = $(this).closest('tr').data('kind');
    dialog({
      title: '提示',
      content: '是否清空绑定?KindID=' + KindID,
      okValue: '确定',
      ok: function () {
        $.post("{:url('user.detail/bindClear')}", {
          uid: "{$User.UserID}",
          kind: KindID
        }, function (resp, text, xhr) {
          console.log(resp);
          alert(resp.error);
          if (resp.errno == 0) {
            location.reload();
          }
        });
        return false;
      },
      cancelValue: '取消',
      cancel: function () {}
    }).showModal();
  });
  
  // 保存账号权限
  $('input[name=btnSaveRight]').click(function () {
    var input = $(this).parents('.tab-content').find(':input');
    var data = input.serialize();
    console.log(data);
    $.post("{:url('user.detail/saveRight')}?uid={$User.UserID}", data, function (resp, text, xhr) {
      alert(resp.error);
      if (resp.errno == 0) {
        location.reload();
      }
    });
  });
  
  // 保存代理设置
  $('input[name=btnSaveAgent]').click(function () {
    var input = $(this).parents('.tab-content').find(':input');
    var data = input.serialize();
    console.log(data);
    $.post("{:url('user.detail/saveAgent')}?uid={$User.UserID}", data, function (resp, text, xhr) {
      alert(resp.error);
      if (resp.errno == 0) {
        location.reload();
      }
    });
  });

});
</script>
</body>
{/block}